//
//  BNDEnterpriseShowView.m
//  OfficeDoc
//
//  Created by pie on 2022/3/31.
//  Copyright © 2022 pie. All rights reserved.
//

#import "BNDEnterpriseShowView.h"

@interface BNDEnterpriseShowView ()
@property (nonatomic, strong) UILabel * titleLabel;
@property (nonatomic, strong) UILabel * companyLabel;
@property (nonatomic, strong) UIView * showView;
@end

@implementation BNDEnterpriseShowView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColor.whiteColor;
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = BNDPFHeavyFont(14);
        _titleLabel.textColor = UIColorWithHex(0x79859D);
        _titleLabel.text = @"公告发布企业";
        _titleLabel.numberOfLines = 1;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.mas_left).offset(16);
            make.centerY.mas_equalTo(self);
        }];
        
        _showView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 34)];
        _showView.backgroundColor = UIColorWithHex(0xF6F6F8);
        _showView.layer.cornerRadius = 8;
        [self addSubview:_showView];
      
        

        UIImageView *tipImageView = [[UIImageView alloc] initWithImage:BNDImageNamed(@"bnd_company_tip")];
        [self.showView addSubview:tipImageView];
        [tipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.showView).offset(10);
            make.centerY.mas_equalTo(self.showView);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UIImageView *moreImageView = [[UIImageView alloc] initWithImage:BNDImageNamed(@"bnd_company_more")];
        [self.showView addSubview:moreImageView];
        [moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.showView.mas_right).offset(-12);
            make.centerY.mas_equalTo(self.showView);
            make.size.mas_equalTo(CGSizeMake(16, 16));
        }];
        
        _companyLabel = [[UILabel alloc] init];
        _companyLabel.font = BNDPFRegularFont(14);
        _companyLabel.textColor = UIColorWithHex(0x2F2F2F);
        _companyLabel.text = [BNDPreference sharedInstance].companyName;
        _companyLabel.textAlignment = NSTextAlignmentCenter;
        _companyLabel.numberOfLines = 1;
        [self.showView addSubview:_companyLabel];
        [_companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
           make.width.mas_lessThanOrEqualTo(kDeviceWidth-210);
           make.center.mas_equalTo(self.showView);
        }];
        
        [_showView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLabel.mas_right).offset(8);
            make.right.mas_equalTo(self.mas_right).offset(-34);
            make.height.mas_equalTo(34);
            make.centerY.mas_equalTo(self.titleLabel);
        }];
        
//        UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [self.showView addSubview:clickBtn];
//        [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.edges.mas_equalTo(UIEdgeInsetsZero);
//        }];
//        
//        @weakify(self)
//        [[clickBtn
//        rac_signalForControlEvents:UIControlEventTouchUpInside]
//        subscribeNext:^(id x) {
//          @strongify(self)
//            BND_BLOCK_EXEC(self.block,@"");
//        }];
    }
    
    return self;
}

- (void)setModel:(BNDChooseCompanyModel *)model
{
    _model = model;
    _companyLabel.text = model.companyName;
}

@end
